<!-- HTML header for doxygen 1.8.3.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.3.1"/>
<title>Sifteo SDK: bg2.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-style-overrides.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<center>
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Sifteo SDK" src="sdk_logo.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">
   &#160;<span id="projectnumber">v1.0.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
</center>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Home</span></a></li>
      <li><a href="pages.html"><span>Guides</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Reference</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_12cda917fe1d7c8b4e7d2501bb3636e4.html">sdk</a></li><li class="navelem"><a class="el" href="dir_2f23e30b638d6a5f333babd9a5d183e1.html">include</a></li><li class="navelem"><a class="el" href="dir_d5ace589187da7c83c1a7507ec9fbbef.html">sifteo</a></li><li class="navelem"><a class="el" href="dir_483499650334b406c1d3bbaf3a730f60.html">video</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">bg2.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/* -*- mode: C; c-basic-offset: 4; intent-tabs-mode: nil -*-</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> * This file is part of the public interface to the Sifteo SDK.</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * Copyright &lt;c&gt; 2012 Sifteo, Inc. All rights reserved.</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;</div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#pragma once</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#ifdef NOT_USERSPACE</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#   error This is a userspace-only header, not allowed by the current build.</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#include &lt;sifteo/abi.h&gt;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &lt;sifteo/macros.h&gt;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#include &lt;sifteo/math.h&gt;</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="preprocessor">#include &lt;sifteo/asset.h&gt;</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="preprocessor">#include &lt;sifteo/video/color.h&gt;</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;</div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="keyword">namespace </span>Sifteo {</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;</div>
<div class="line"><a name="l00042"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html">   42</a></span>&#160;<span class="keyword">struct </span><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html" title="A VRAM accessor for drawing graphics in the BG2 mode.">BG2Drawable</a> {</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    _SYSAttachedVideoBuffer sys;</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;</div>
<div class="line"><a name="l00048"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a719f833bad10286b2af95e95eeb498b3">   48</a></span>&#160;    <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a719f833bad10286b2af95e95eeb498b3" title="Return the width, in tiles, of this mode.">tileWidth</a>() {</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;        <span class="keywordflow">return</span> _SYS_VRAM_BG2_WIDTH;</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;    }</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;</div>
<div class="line"><a name="l00055"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a54d6f73dab3eddf8c74ec8b9b6945b55">   55</a></span>&#160;    <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a54d6f73dab3eddf8c74ec8b9b6945b55" title="Return the height, in tiles, of this mode.">tileHeight</a>() {</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;        <span class="keywordflow">return</span> _SYS_VRAM_BG2_WIDTH;</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;    }</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;</div>
<div class="line"><a name="l00062"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#ac2c57141d252b8d8c518636d61b354be">   62</a></span>&#160;    <span class="keyword">static</span> <a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#ac2c57141d252b8d8c518636d61b354be" title="Return the size of this mode as a vector, in tiles.">tileSize</a>() {</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="group__math.html#gab18c9af04a4a3a4a3c63656e40ab74ed" title="Create a Vector2, from a set of (x,y) coordinates.">vec</a>(<a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a719f833bad10286b2af95e95eeb498b3" title="Return the width, in tiles, of this mode.">tileWidth</a>(), <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a54d6f73dab3eddf8c74ec8b9b6945b55" title="Return the height, in tiles, of this mode.">tileHeight</a>());</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;    }</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;</div>
<div class="line"><a name="l00069"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a5792d755bbfc96e9c82423b940885c79">   69</a></span>&#160;    <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a5792d755bbfc96e9c82423b940885c79" title="Return the width, in pixels, of this mode.">pixelWidth</a>() {</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a719f833bad10286b2af95e95eeb498b3" title="Return the width, in tiles, of this mode.">tileWidth</a>() * 8;</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;    }</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;</div>
<div class="line"><a name="l00076"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a0b2a811a943befd81191b37d18a20bdb">   76</a></span>&#160;    <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a0b2a811a943befd81191b37d18a20bdb" title="Return the height, in pixel, of this mode.">pixelHeight</a>() {</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a54d6f73dab3eddf8c74ec8b9b6945b55" title="Return the height, in tiles, of this mode.">tileHeight</a>() * 8;</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;    }</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;</div>
<div class="line"><a name="l00083"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a4668fe654ee9304ef1ad007c74835828">   83</a></span>&#160;    <span class="keyword">static</span> <a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a4668fe654ee9304ef1ad007c74835828" title="Return the size of this mode as a vector, in pixels.">pixelSize</a>() {</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="group__math.html#gab18c9af04a4a3a4a3c63656e40ab74ed" title="Create a Vector2, from a set of (x,y) coordinates.">vec</a>(<a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a5792d755bbfc96e9c82423b940885c79" title="Return the width, in pixels, of this mode.">pixelWidth</a>(), <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a0b2a811a943befd81191b37d18a20bdb" title="Return the height, in pixel, of this mode.">pixelHeight</a>());</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;    }</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;</div>
<div class="line"><a name="l00090"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#af17c092b857dbb04bea1be248bbda988">   90</a></span>&#160;    <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#af17c092b857dbb04bea1be248bbda988" title="Returns the size of this drawable&#39;s tile data, in bytes.">sizeInBytes</a>() {</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a719f833bad10286b2af95e95eeb498b3" title="Return the width, in tiles, of this mode.">tileWidth</a>() * <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a54d6f73dab3eddf8c74ec8b9b6945b55" title="Return the height, in tiles, of this mode.">tileHeight</a>() * 2;</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;    }</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;</div>
<div class="line"><a name="l00097"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a6e4dc734c35022e6581d8f1fa50f23b7">   97</a></span>&#160;    <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a6e4dc734c35022e6581d8f1fa50f23b7" title="Returns the size of this drawable&#39;s tile data, in 16-bit words.">sizeInWords</a>() {</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a719f833bad10286b2af95e95eeb498b3" title="Return the width, in tiles, of this mode.">tileWidth</a>() * <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a54d6f73dab3eddf8c74ec8b9b6945b55" title="Return the height, in tiles, of this mode.">tileHeight</a>();</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;    }</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;</div>
<div class="line"><a name="l00106"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a57ccb253520fed5b21df56fbb345fb05">  106</a></span>&#160;    uint16_t <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a57ccb253520fed5b21df56fbb345fb05" title="Calculate the video buffer address of a particular tile.">tileAddr</a>(<a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> pos) {</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;        <span class="keywordflow">return</span> pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a> + pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a> * <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a719f833bad10286b2af95e95eeb498b3" title="Return the width, in tiles, of this mode.">tileWidth</a>();</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;    }</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;</div>
<div class="line"><a name="l00116"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#ac3f2bafb7d3461525daec13349a6808d">  116</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#ac3f2bafb7d3461525daec13349a6808d" title="Erase mode-specific VRAM, filling the BG2 buffer with the specified absolute tile index value...">erase</a>(uint16_t index = 0) {</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;        _SYS_vbuf_fill(&amp;sys.vbuf, 0, _SYS_TILE77(index), <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a6e4dc734c35022e6581d8f1fa50f23b7" title="Returns the size of this drawable&#39;s tile data, in 16-bit words.">sizeInWords</a>());</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;    }</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;</div>
<div class="line"><a name="l00124"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#ab5494d922c1e1d276dd66dfac6751be3">  124</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#ab5494d922c1e1d276dd66dfac6751be3" title="Erase mode-specific VRAM, filling the BG2 buffer with the first tile from the specified PinnedAssetIm...">erase</a>(<span class="keyword">const</span> <a class="code" href="struct_sifteo_1_1_pinned_asset_image.html" title="An AssetImage in which all tiles are stored sequentially in memory.">PinnedAssetImage</a> &amp;<a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a8e9f1e5922e81e596d3ac3521af12e4b" title="Draw a full AssetImage frame, with its top-left corner at the specified location.">image</a>) {</div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;        <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#ac3f2bafb7d3461525daec13349a6808d" title="Erase mode-specific VRAM, filling the BG2 buffer with the specified absolute tile index value...">erase</a>(image.<a class="code" href="struct_sifteo_1_1_pinned_asset_image.html#acae95d334dc7ae91830e26cc8389bcb4" title="Returns the index of the tile at linear position &#39;i&#39; in the image.">tile</a>(sys.cube, 0));</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;    }</div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;    </div>
<div class="line"><a name="l00134"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#ad1141ac18e19f20e1a1f54eef1bf0153">  134</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#ad1141ac18e19f20e1a1f54eef1bf0153" title="Set the border color, given an arbitrary 16-bit RGB565 color.">setBorder</a>(<a class="code" href="struct_sifteo_1_1_r_g_b565.html" title="Represents a 16-bit 5:6:5 color, the native format used by our display.">RGB565</a> color) {</div>
<div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;        _SYS_vbuf_poke(&amp;sys.vbuf, <a class="code" href="group__macros.html#gafef9199621fafa1bd046611921ab061f">offsetof</a>(_SYSVideoRAM, bg2_border) / 2,</div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;            color.<a class="code" href="struct_sifteo_1_1_r_g_b565.html#aab28724ae443519720a500a30bc06e34" title="The raw color value, as a 16-bit integer.">value</a>);</div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;    }</div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;</div>
<div class="line"><a name="l00142"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a3247ef14b9ea7b639eed545a6030593f">  142</a></span>&#160;    <a class="code" href="struct_sifteo_1_1_r_g_b565.html" title="Represents a 16-bit 5:6:5 color, the native format used by our display.">RGB565</a> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a3247ef14b9ea7b639eed545a6030593f" title="Get the last border color set by setBorder().">getBorder</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;        <a class="code" href="struct_sifteo_1_1_r_g_b565.html" title="Represents a 16-bit 5:6:5 color, the native format used by our display.">RGB565</a> result = { _SYS_vbuf_peek(&amp;sys.vbuf, <a class="code" href="group__macros.html#gafef9199621fafa1bd046611921ab061f">offsetof</a>(_SYSVideoRAM, bg2_border)) };</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;        <span class="keywordflow">return</span> result;</div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;    }</div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;</div>
<div class="line"><a name="l00150"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#ad036c532e33e6e2c998e955c0dbba08b">  150</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#ad036c532e33e6e2c998e955c0dbba08b" title="Set the current affine transform matrix.">setMatrix</a>(<span class="keyword">const</span> <a class="code" href="struct_sifteo_1_1_affine_matrix.html" title="An augmented 3x2 matrix, for doing 2D affine transforms.">AffineMatrix</a> &amp;m) {</div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;        _SYSAffine a = {</div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;            <span class="comment">// Round to fixed-point</span></div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;            256.0f * m.<a class="code" href="struct_sifteo_1_1_affine_matrix.html#a1159378a07ac177ee26ba7460e77efc8" title="Matrix member cx, the constant offset for X.">cx</a> + 0.5f,</div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;            256.0f * m.<a class="code" href="struct_sifteo_1_1_affine_matrix.html#a633cc1c8eb9d03698e395230ee3b5ef4" title="Matrix member cy, the constant offset for Y.">cy</a> + 0.5f,</div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;            256.0f * m.<a class="code" href="struct_sifteo_1_1_affine_matrix.html#ac26e83ff5e2698516813b3032c8b9795" title="Matrix member xx, the horizontal X delta.">xx</a> + 0.5f,</div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;            256.0f * m.<a class="code" href="struct_sifteo_1_1_affine_matrix.html#a9b3fcff7820d2ab5d160f74204723e65" title="Matrix member xy, the horizontal Y delta.">xy</a> + 0.5f,</div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;            256.0f * m.<a class="code" href="struct_sifteo_1_1_affine_matrix.html#ada7a312253d20f2dfc734d6a6b8a0428" title="Matrix member yx, the vertical X delta.">yx</a> + 0.5f,</div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;            256.0f * m.<a class="code" href="struct_sifteo_1_1_affine_matrix.html#aa32dde48158e502f49be4956cd67f43b" title="Matrix member yy, the vertical Y delta.">yy</a> + 0.5f,</div>
<div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;        };</div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;        _SYS_vbuf_write(&amp;sys.vbuf, <a class="code" href="group__macros.html#gafef9199621fafa1bd046611921ab061f">offsetof</a>(_SYSVideoRAM, bg2_affine)/2,</div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;                        (<span class="keyword">const</span> uint16_t *)&amp;a, 6);</div>
<div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;    }</div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;</div>
<div class="line"><a name="l00170"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#ad751ad7e861bbee7157834e81bd8a73d">  170</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#ad751ad7e861bbee7157834e81bd8a73d" title="Plot a single tile, by absolute tile index, at location &#39;pos&#39; in tile units.">plot</a>(<a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> pos, uint16_t tileIndex) {</div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;        <a class="code" href="group__macros.html#ga8a15779356736a0900a162442b1cda53" title="Runtime debug assertion.">ASSERT</a>(pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a> &lt; <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a719f833bad10286b2af95e95eeb498b3" title="Return the width, in tiles, of this mode.">tileWidth</a>() &amp;&amp; pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a> &lt; <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a54d6f73dab3eddf8c74ec8b9b6945b55" title="Return the height, in tiles, of this mode.">tileHeight</a>());</div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;        _SYS_vbuf_poke(&amp;sys.vbuf, <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a57ccb253520fed5b21df56fbb345fb05" title="Calculate the video buffer address of a particular tile.">tileAddr</a>(pos), _SYS_TILE77(tileIndex));</div>
<div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;    }</div>
<div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;</div>
<div class="line"><a name="l00181"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a6feffa2e0941af0de499f9bb171afe95">  181</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a6feffa2e0941af0de499f9bb171afe95" title="Plot a horizontal span of tiles, by absolue tile index, given the position of the leftmost tile and t...">span</a>(<a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> pos, <span class="keywordtype">unsigned</span> width, <span class="keywordtype">unsigned</span> tileIndex)</div>
<div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;    {</div>
<div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;        <a class="code" href="group__macros.html#ga8a15779356736a0900a162442b1cda53" title="Runtime debug assertion.">ASSERT</a>(pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a> &lt;= <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a719f833bad10286b2af95e95eeb498b3" title="Return the width, in tiles, of this mode.">tileWidth</a>() &amp;&amp; width &lt;= <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a719f833bad10286b2af95e95eeb498b3" title="Return the width, in tiles, of this mode.">tileWidth</a>() &amp;&amp;</div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;            (pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a> + width) &lt;= <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a719f833bad10286b2af95e95eeb498b3" title="Return the width, in tiles, of this mode.">tileWidth</a>() &amp;&amp; pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a> &lt; <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a54d6f73dab3eddf8c74ec8b9b6945b55" title="Return the height, in tiles, of this mode.">tileHeight</a>());</div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;        _SYS_vbuf_fill(&amp;sys.vbuf, <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a57ccb253520fed5b21df56fbb345fb05" title="Calculate the video buffer address of a particular tile.">tileAddr</a>(pos), _SYS_TILE77(tileIndex), width);</div>
<div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;    }</div>
<div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;</div>
<div class="line"><a name="l00194"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a8b5b5f6933bf76a1d93dd7f4ac2c2cee">  194</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a8b5b5f6933bf76a1d93dd7f4ac2c2cee" title="Fill a rectangle of identical tiles, specified as a top-left corner location and a size...">fill</a>(<a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> topLeft, <a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> size, <span class="keywordtype">unsigned</span> tileIndex)</div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;    {</div>
<div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;        <span class="keywordflow">while</span> (size.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a>) {</div>
<div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;            <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a6feffa2e0941af0de499f9bb171afe95" title="Plot a horizontal span of tiles, by absolue tile index, given the position of the leftmost tile and t...">span</a>(topLeft, size.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a>, tileIndex);</div>
<div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;            size.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a>--;</div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;            topLeft.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a>++;</div>
<div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;        }</div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;    }</div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;</div>
<div class="line"><a name="l00211"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a8e9f1e5922e81e596d3ac3521af12e4b">  211</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a8e9f1e5922e81e596d3ac3521af12e4b" title="Draw a full AssetImage frame, with its top-left corner at the specified location.">image</a>(<a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> pos, <span class="keyword">const</span> <a class="code" href="struct_sifteo_1_1_asset_image.html" title="Any kind of asset image, as defined in your stir script.">AssetImage</a> &amp;<a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a8e9f1e5922e81e596d3ac3521af12e4b" title="Draw a full AssetImage frame, with its top-left corner at the specified location.">image</a>, <span class="keywordtype">unsigned</span> frame = 0)</div>
<div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;    {</div>
<div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;        _SYS_image_BG2Draw(&amp;sys, image, <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a57ccb253520fed5b21df56fbb345fb05" title="Calculate the video buffer address of a particular tile.">tileAddr</a>(pos), frame);</div>
<div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;    }</div>
<div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;</div>
<div class="line"><a name="l00224"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#ab90a83427057e1787d7c8f7d3ea7c43a">  224</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a8e9f1e5922e81e596d3ac3521af12e4b" title="Draw a full AssetImage frame, with its top-left corner at the specified location.">image</a>(<a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> destXY, <a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> size, <span class="keyword">const</span> <a class="code" href="struct_sifteo_1_1_asset_image.html" title="Any kind of asset image, as defined in your stir script.">AssetImage</a> &amp;<a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a8e9f1e5922e81e596d3ac3521af12e4b" title="Draw a full AssetImage frame, with its top-left corner at the specified location.">image</a>, <a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> srcXY, <span class="keywordtype">unsigned</span> frame = 0)</div>
<div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;    {</div>
<div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;        _SYS_image_BG2DrawRect(&amp;sys, image, <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a57ccb253520fed5b21df56fbb345fb05" title="Calculate the video buffer address of a particular tile.">tileAddr</a>(destXY),</div>
<div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;            frame, (_SYSInt2*) &amp;srcXY, (_SYSInt2*) &amp;size);</div>
<div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;    }</div>
<div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;</div>
<div class="line"><a name="l00236"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#aadca759b87113d1189d357f53c726013">  236</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#aadca759b87113d1189d357f53c726013" title="Draw text, using an AssetImage as a fixed width font.">text</a>(<a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">Int2</a> topLeft, <span class="keyword">const</span> <a class="code" href="struct_sifteo_1_1_asset_image.html" title="Any kind of asset image, as defined in your stir script.">AssetImage</a> &amp;font, <span class="keyword">const</span> <span class="keywordtype">char</span> *str, <span class="keywordtype">char</span> firstChar = <span class="charliteral">&#39; &#39;</span>)</div>
<div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;    {</div>
<div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;        <span class="keywordtype">unsigned</span> addr = <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a57ccb253520fed5b21df56fbb345fb05" title="Calculate the video buffer address of a particular tile.">tileAddr</a>(topLeft);</div>
<div class="line"><a name="l00239"></a><span class="lineno">  239</span>&#160;        <span class="keywordtype">unsigned</span> lineAddr = addr;</div>
<div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160;        <span class="keywordtype">char</span> c;</div>
<div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;</div>
<div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160;        <span class="keywordflow">while</span> ((c = *str)) {</div>
<div class="line"><a name="l00243"></a><span class="lineno">  243</span>&#160;            <span class="keywordflow">if</span> (c == <span class="charliteral">&#39;\n&#39;</span>) {</div>
<div class="line"><a name="l00244"></a><span class="lineno">  244</span>&#160;                addr = (lineAddr += font.<a class="code" href="struct_sifteo_1_1_asset_image.html#a7ff2fd5e83e49e79b376df2c8b156bbd" title="The height of this image, in tiles.">tileHeight</a>() * <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a719f833bad10286b2af95e95eeb498b3" title="Return the width, in tiles, of this mode.">tileWidth</a>());</div>
<div class="line"><a name="l00245"></a><span class="lineno">  245</span>&#160;            } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00246"></a><span class="lineno">  246</span>&#160;                _SYS_image_BG2Draw(&amp;sys, font, addr, c - firstChar);</div>
<div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;                addr += font.<a class="code" href="struct_sifteo_1_1_asset_image.html#adaba620b7063de2be6abba13e9857169" title="The width of this image, in tiles.">tileWidth</a>();</div>
<div class="line"><a name="l00248"></a><span class="lineno">  248</span>&#160;            }</div>
<div class="line"><a name="l00249"></a><span class="lineno">  249</span>&#160;            str++;</div>
<div class="line"><a name="l00250"></a><span class="lineno">  250</span>&#160;        }</div>
<div class="line"><a name="l00251"></a><span class="lineno">  251</span>&#160;    }</div>
<div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;</div>
<div class="line"><a name="l00256"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a7fb8b63d0967c2dec4d8face8a77d322">  256</a></span>&#160;    _SYSVideoBuffer &amp;<a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a7fb8b63d0967c2dec4d8face8a77d322" title="Return the VideoBuffer associated with this drawable.">videoBuffer</a>() {</div>
<div class="line"><a name="l00257"></a><span class="lineno">  257</span>&#160;        <span class="keywordflow">return</span> sys.vbuf;</div>
<div class="line"><a name="l00258"></a><span class="lineno">  258</span>&#160;    }</div>
<div class="line"><a name="l00259"></a><span class="lineno">  259</span>&#160;</div>
<div class="line"><a name="l00263"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a42018e930ac090e1ebb2b505844055c3">  263</a></span>&#160;    <a class="code" href="struct_sifteo_1_1_cube_i_d.html" title="A lightweight identifier for one Sifteo cube.">CubeID</a> <a class="code" href="struct_sifteo_1_1_b_g2_drawable.html#a42018e930ac090e1ebb2b505844055c3" title="Return the CubeID associated with this drawable.">cube</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;        <span class="keywordflow">return</span> sys.cube;</div>
<div class="line"><a name="l00265"></a><span class="lineno">  265</span>&#160;    }</div>
<div class="line"><a name="l00266"></a><span class="lineno">  266</span>&#160;};</div>
<div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;</div>
<div class="line"><a name="l00272"></a><span class="lineno">  272</span>&#160;};  <span class="comment">// namespace Sifteo</span></div>
</div><!-- fragment --></div><!-- contents -->
<!-- HTML footer for doxygen 1.8.3.1-->
<!-- start footer part -->
    <hr class="footer"/>
    <address class="footer">
        <p><a href="http://sifteo.com">Sifteo</a> SDK v1.0.0 <small>(see <a href="https://developers.sifteo.com/sifteosdk">all versions</a>)</small></p>
        <p>Last updated Wed Mar 27 2013, by <a href="http://www.stack.nl/~dimitri/doxygen">Doxygen</a></p>
    </address>
</body>
</html>
